using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Threading;
using System.Diagnostics;
using System.Collections;

using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Net.Sockets;
using BrainTechLLC;

namespace Mud.EmlenMudMain
{
    [Serializable]
    public class ClanData : GameThingBaseClass, IClanData
    {
        public ClanData() { }
        public const int MAX_CLAN_STORAGE = 30;	/* How many items can a clan have in their clan rgObjectsStored? */

        private int vnumClan;			        /* Clan vnum */
        private string clanLeader = "";		/* Name of Clan's Leader/Owner */
        private int vnumClanhouseStart;		/* Starting vnumClan of where clanhouse begins */
        private int alignment = 0;		/* 1=good,2=evil,0=neut,3=special */
        private int minLevelToJoin;		/* Minlevel of new rgMemberNames */
        private List<string> rgMemberNames = new List<string>(); /* Clan rgMemberNames */
        private List<long> rgObjectsStored = new List<long>(); /* Clan rgObjectsStored */


        public int VnumClan
        {
            get { return vnumClan; }
            set { vnumClan = value; }
        }

        public string ClanLeader
        {
            get { return clanLeader; }
            set { clanLeader = value; }
        }

        public int RoomVnumClanhouseStart
        {
            get { return vnumClanhouseStart; }
            set { vnumClanhouseStart = value; }
        }

        public int ClanAlignment
        {
            get { return alignment; }
            set { alignment = value; }
        }

        public int MinimumLevelRequiredToJoin
        {
            get { return minLevelToJoin; }
            set { minLevelToJoin = value; }
        }

        public List<string> ClanMemberNames
        {
            get { return rgMemberNames; }
            set { rgMemberNames = value; }
        }

        public List<long> StoredClanObjects
        {
            get { return rgObjectsStored; }
            set { rgObjectsStored = value; }
        }

        public static bool Load(int n, int inVersion)
        {
            if (ClanData.SerializeIn(n, inVersion) == false)
            {
                if (n == 1) EmlenMud.Oldschool.load_clans_old_format();
                else EmlenMud.Oldschool.load_clans_2_old_format();

                if (n == 1 && EmlenMud.WorldTemplates.AllClans.Count == 0)
                {
                    ClanData.SerializeOut(n, inVersion);
                }
                if (n == 2 && EmlenMud.WorldTemplates.AllSects.Count == 0)
                {
                    ClanData.SerializeOut(n, inVersion);
                }
            }
            return true;
        }

        public static bool Save(int n, int outVersion)
        {
            return ClanData.SerializeOut(n, outVersion);
        }

        public static bool SerializeIn(int n, int inVersion)
        {
#if NO_SILVERLIGHT
            string szFName = EmlenMud.HostPathnameToMudDirectory + "\\" + MiscConstants.DataFileDirectory + "\\" + typeof(ClanData).Name.ToString() + n.ToString() + inVersion.ToString();
            Object o = SerializationHelper.SerializeObjectIn(szFName);
            if (o == null) return false;
            if (o is ArrayList)
            {
                ArrayList rgclans = (ArrayList)o;
                for (int i = 0; i < rgclans.Count; i++)
                {
                    ClanData cd = (ClanData)rgclans[i];
                    //cd.AssignEmlenMud();
                    if (n == 1) EmlenMud.WorldTemplates.AllClans.Add(cd);
                    else if (n == 2) EmlenMud.WorldTemplates.AllSects.Add(cd);
                }
                return true;
            }
            return false;
#else
            return true;
#endif
        }

        public static bool SerializeOut(int n, int outVersion)
        {
#if NO_SILVERLIGHT
            string szFName = EmlenMud.HostPathnameToMudDirectory + "\\" + MiscConstants.DataFileDirectory + "\\" + typeof(ClanData).Name.ToString() + n.ToString() + outVersion.ToString();
            if (n == 1) return SerializationHelper.SerializeObjectOut(EmlenMud.WorldTemplates.AllClans, szFName, true);
            else return SerializationHelper.SerializeObjectOut(EmlenMud.WorldTemplates.AllSects, szFName, true);
#else
            return true;
#endif
        }

        // OLD CODE to PORT (some may already be done...) I have no idea why there
        // is clan and sect.......


        //void do_cindex_2 (CharacterData  chr, string szUserArguments)
        //{
        //  char buf[STD_LENGTH];
        //  char line[STD_LENGTH];
        //  char arg[SML_LENGTH];
        //  CLAN_DATA *clan;
        //  int iAtt;
        //  int cnt;
        //  one_argy (szUserArguments, arg);
        //  if (arg[0] == '\0')
        //    {
        //      send_to_char ("Cindex which clan?\n\r", chr);
        //      return;
        //    }
        //  if ((clan = get_clan_index_2 (atoi (arg))) == NULL)
        //    {
        //      send_to_char ("Invalid clan VNUM.\n\r", chr);
        //      return;
        //    }
        //  sprintf (buf, "\n\r\x1B[30;1m[\x1B[34;1mClan Number: %d\x1B[30;1m] \x1B[37;1m(%s)\x1B[0m\n\r\n\r", clan->vnumClan, clan->name);
        //  send_to_char (buf, chr);
        //  sprintf (buf, "Clan Leader/Founder: \x1B[37;1m%s\x1B[0m\n\r", clan->clanLeader);
        //  send_to_char (buf, chr);
        //  sprintf (buf, "Minimum MinimumLevelToViewTopic Entry: %d\n\r", clan->minLevelToJoin);
        //  send_to_char (buf, chr);
        //  sprintf (buf, "Clanzone starting VnumRoom: %d\n\r", clan->vnumClanhouseStart);
        //  send_to_char (buf, chr);
        //  if (clan->alignment == 0)
        //    sprintf (buf, "Clan ClanAlignment: Neutral\n\r\n\r");
        //  if (clan->alignment == 1)
        //    sprintf (buf, "Clan ClanAlignment:\x1B[37;1m Good\n\r\n\r\x1B[0m");
        //  if (clan->alignment == 2)
        //    sprintf (buf, "Clan ClanAlignment:\x1B[30;1m Evil\n\r\n\r\x1B[37;0m");
        //  if (clan->alignment == 3)
        //    sprintf (buf, "Clan ClanAlignment: Special - Good or Neutral\n\r\n\r");
        //  send_to_char (buf, chr);
        //  sprintf (buf, "-----[\x1B[34;1mClan Members\x1B[37;0m]----------------------->\n\r\n\r");
        //  send_to_char (buf, chr);
        //  cnt = 0;
        //  line[0] = '\0';
        //  for (iAtt = 0; iAtt < 100; iAtt = iAtt + 1)
        //    {
        //      if (clan->rgMemberNames[iAtt] == NULL || clan->rgMemberNames[iAtt][0] == ' ')
        //   continue;
        //      sprintf (buf, " %-15s ", clan->rgMemberNames[iAtt]);
        //      strcat (line, buf);
        //      ++cnt;
        //      if (cnt == 4)
        //   {
        //     cnt = 0;
        //     strcat (line, "\n\r");
        //     send_to_char (line, chr);
        //     line[0] = '\0';
        //   }
        //    }
        //  if (cnt != 0)
        //    {
        //      strcat (line, "\n\r");
        //      send_to_char (line, chr);
        //    }
        //  return;
        //}


        //void do_cindex (CharacterData  chr, string szUserArguments)
        //{
        //  char buf[STD_LENGTH];
        //  char line[STD_LENGTH];
        //  char arg[SML_LENGTH];
        //  CLAN_DATA *clan;
        //  int iAtt;
        //  int cnt;
        //  one_argy (szUserArguments, arg);
        //  if (arg[0] == '\0')
        //    {
        //      send_to_char ("Cindex which clan?\n\r", chr);
        //      return;
        //    }
        //  if ((clan = get_clan_index (atoi (arg))) == NULL)
        //    {
        //      send_to_char ("Invalid clan VNUM.\n\r", chr);
        //      return;
        //    }
        //  sprintf (buf, "\n\r\x1B[30;1m[\x1B[34;1mClan Number: %d\x1B[30;1m] \x1B[37;1m(%s)\x1B[0m\n\r\n\r", clan->vnumClan, clan->name);
        //  send_to_char (buf, chr);
        //  sprintf (buf, "Clan Leader/Founder: \x1B[37;1m%s\x1B[0m\n\r", clan->clanLeader);
        //  send_to_char (buf, chr);
        //  sprintf (buf, "Minimum MinimumLevelToViewTopic Entry: %d\n\r", clan->minLevelToJoin);
        //  send_to_char (buf, chr);
        //  sprintf (buf, "Clanzone starting VnumRoom: %d\n\r", clan->vnumClanhouseStart);
        //  send_to_char (buf, chr);
        //  if (clan->alignment == 0)
        //    sprintf (buf, "Clan ClanAlignment: Neutral\n\r\n\r");
        //  if (clan->alignment == 1)
        //    sprintf (buf, "Clan ClanAlignment:\x1B[37;1m Good\n\r\n\r\x1B[0m");
        //  if (clan->alignment == 2)
        //    sprintf (buf, "Clan ClanAlignment:\x1B[30;1m Evil\n\r\n\r\x1B[37;0m");
        //  if (clan->alignment == 3)
        //    sprintf (buf, "Clan ClanAlignment: Special - Good or Neutral\n\r\n\r");
        //  send_to_char (buf, chr);
        //  sprintf (buf, "-----[\x1B[34;1mClan Members\x1B[37;0m]----------------------->\n\r\n\r");
        //  send_to_char (buf, chr);
        //  cnt = 0;
        //  line[0] = '\0';
        //  for (iAtt = 0; iAtt < 100; iAtt = iAtt + 1)
        //    {
        //      if (clan->rgMemberNames[iAtt] == NULL || clan->rgMemberNames[iAtt][0] == ' ')
        //   continue;
        //      sprintf (buf, " %-15s ", clan->rgMemberNames[iAtt]);
        //      strcat (line, buf);
        //      ++cnt;
        //      if (cnt == 4)
        //   {
        //     cnt = 0;
        //     strcat (line, "\n\r");
        //     send_to_char (line, chr);
        //     line[0] = '\0';
        //   }
        //    }
        //  if (cnt != 0)
        //    {
        //      strcat (line, "\n\r");
        //      send_to_char (line, chr);
        //    }
        //  return;
        //}



        //CLAN_DATA *new_clan_index_2 (void)
        //{
        //  CLAN_DATA *ClanData;
        //  int iAttack;
        //  if (clan_index_free_2 == NULL)
        //    {
        //      ClanData = new CLAN_DATA; //  (sizeof (*ClanData));
        //      top_clan_2++;
        //    }
        //  else
        //    {
        //      ClanData = clan_index_free_2;
        //      clan_index_free_2 = clan_index_free_2->next;
        //    }
        //  ClanData->clanLeader[0] = '\0';
        //  ClanData->name[0] = '\0';
        //  ClanData->alignment = 0;
        //  ClanData->minLevelToJoin = 0;
        //  ClanData->vnumClanhouseStart = 0;
        //  for (iAttack = 0; iAttack <= 100; iAttack++)
        //    ClanData->rgMemberNames[iAttack] = NULL;
        //  return ClanData;
        //}

        //void cedit (CharacterData  chr, string szUserArguments)
        //{
        //  CLAN_DATA *ClanData;
        //  char arg[STD_LENGTH];
        //  char arg1[STD_LENGTH];
        //  char arg2[STD_LENGTH];
        //  char buf[STD_LENGTH];
        //  int value;
        //  strcpy (arg, szUserArguments);
        //  ClanData = (CLAN_DATA *) chr->description->pEdit;
        //  smash_tilde (szUserArguments);
        //  szUserArguments = one_argy (szUserArguments, arg1);
        //  strcpy (arg2, szUserArguments);
        //  value = atoi (arg2);
        //  if (!str_cmp (arg1, "show") || arg1[0] == '\0')
        //    {
        //      sprintf (buf, "%d", ClanData->vnumClan);
        //      if (chr->fightInfoInternal->attacker_turn)
        //   do_cindex_2 (chr, buf);
        //      else
        //   do_cindex (chr, buf);
        //      return;
        //    }
        //  if (!str_cmp (arg1, "done"))
        //    {
        //      chr->description->pEdit = NULL;
        //      chr->description->connected = PLAYING;
        //      send_to_char ("Please remember to ASAVE CLANS. :)\n\r", chr);
        //      return;
        //    }
        //  if (!str_cmp (arg1, "clanLeader") && arg2[0] != '\0')
        //    {
        //      strcpy (ClanData->clanLeader, arg2);
        //      send_to_char ("Clan Leader Set.\n\r", chr);
        //      return;
        //    }
        //  if (!str_cmp (arg1, "name") && arg2[0] != '\0')
        //    {
        //      strcpy (ClanData->name, arg2);
        //      send_to_char ("Clan Name Set.\n\r", chr);
        //      return;
        //    }
        //  if (!str_cmp (arg1, "good"))
        //    {
        //      ClanData->alignment = 1;
        //      send_to_char ("Clan alignment set.\n\r", chr);
        //      return;
        //    }
        //  if (!str_cmp (arg1, "neutral"))
        //    {
        //      ClanData->alignment = 0;
        //      send_to_char ("Clan alignment set.\n\r", chr);
        //      return;
        //    }
        //  if (!str_cmp (arg1, "evil"))
        //    {
        //      ClanData->alignment = 2;
        //      send_to_char ("Clan alignment set.\n\r", chr);
        //      return;
        //    }
        //  if (!str_cmp (arg1, "special"))
        //    {
        //      ClanData->alignment = 3;
        //      send_to_char ("Clan alignment set.\n\r", chr);
        //      return;
        //    }
        //  if ((!str_cmp (arg1, "start") || !str_cmp (arg1, "vnumClan")) &&
        //      is_number (arg2) && value >= 0)
        //    {
        //      ROOM_DATA *rcheck;
        //      rcheck = get_room_index (value);
        //      if (rcheck == NULL)
        //   {
        //     send_to_char ("Invalid Starting VNUM.\n\r", chr);
        //     return;
        //   }
        //      ClanData->vnumClanhouseStart = value;
        //      send_to_char ("Clan starting VNUM of clanhouse set.\n\r", chr);
        //      return;
        //    }
        //  if (
        //       (!str_cmp (arg1, "minLevelToJoin") ||
        //   !str_cmp (arg1, "level") ||
        //   !str_cmp (arg1, "minimum") ||
        //   !str_cmp (arg1, "minlevel"))
        //       && is_number (arg2) && value >= 0)
        //    {
        //      ClanData->minLevelToJoin = value;
        //      send_to_char ("Clan minimum entry level set.\n\r", chr);
        //      return;
        //    }
        //  if (!str_cmp (arg1, "add") && arg2[0] != '\0' && strlen (arg2) > 2)
        //    {
        //      int cnum;
        //      char buffy[255];
        //      arg2[0] = UPPER (arg2[0]);
        //      if (check_clan (ClanData, arg2))
        //   {
        //     send_to_char ("That person is already a member!\n\r", chr);
        //     return;
        //   }
        //      cnum = clan_free (ClanData);
        //      if (cnum < 0)
        //   {
        //     send_to_char ("Clan is FULL!\n\r", chr);
        //     return;
        //   }
        //      ClanData->rgMemberNames[cnum] = str_dup (arg2);
        //      send_to_char ("Clan member added!\n\r", chr);
        //      sprintf (buffy, "%s is now a member of the clan!", arg2);
        //      clan_notify (buffy, ClanData->vnumClan);
        //      return;
        //    }
        //  if (!str_cmp (arg1, "remove") && arg2[0] != '\0' && strlen (arg2) > 2)
        //    {
        //      int i;
        //      bool foundy;
        //      foundy = FALSE;
        //      for (i = 0; i < 100; i++)
        //   {
        //     if (!str_cmp (ClanData->rgMemberNames[i], arg2))
        //       {
        //         free_string (ClanData->rgMemberNames[i]);
        //         ClanData->rgMemberNames[i] = NULL;
        //         foundy = TRUE;
        //         break;
        //       }
        //   }
        //      if (foundy)
        //   send_to_char ("Clan member removed.\n\r", chr);
        //      else
        //   send_to_char ("Clan member not found.\n\r", chr);
        //      return;
        //    }
        //  interpret (chr, arg);
        //  return;
        //}


        //void do_cadd (CharacterData  chr, string szUserArguments)
        //{
        //  CLAN_DATA *ClanData;
        //  char t[STD_LENGTH];
        //  int i;
        //  DEFINE_COMMAND ("cadd", do_cadd, POSITION_DEAD, 0, NORMAL, "Adds a member to the clan.  For the clan clanLeader only.")

        //    if (IS_MOB (chr))
        //    return;
        //  strcpy (t, szUserArguments);
        //  for (i = 0; t[i] != '\0'; i++)
        //    {
        //      if (!isalpha (t[i]))
        //   {
        //     send_to_char ("No SPACES or non-letters can't be used!\n\r", chr);
        //     return;
        //   }
        //    }
        //  if (clan_number (chr) < 1)
        //    {
        //      send_to_char ("You are not a clan clanLeader!!\n\r", chr);
        //      return;
        //    }
        //  if (szUserArguments == "" || szUserArguments[0] == '\0')
        //    {
        //      send_to_char ("Syntax: CADD <membername>\n\r", chr);
        //      return;
        //    }
        //  ClanData = get_clan_index (clan_number (chr));
        //  if (str_cmp (chr->pcdata->name, ClanData->clanLeader))
        //    {
        //      send_to_char ("Only the clan clanLeader may add rgMemberNames.\n\r", chr);
        //      return;
        //    }
        //  if (scan_clan (szUserArguments))
        //    {
        //      send_to_char ("That person is already in another clan!\n\r", chr);
        //      return;
        //    }
        //  {
        //    int cnum;
        //    char buffy[255];
        //    szUserArguments[0] = UPPER (szUserArguments[0]);
        //    if (check_clan (ClanData, szUserArguments))
        //      {
        //   send_to_char ("That person is already a member!\n\r", chr);
        //   return;
        //      }
        //    cnum = clan_free (ClanData);
        //    if (cnum < 0)
        //      {
        //   send_to_char ("Clan is FULL!\n\r", chr);
        //   return;
        //      }
        //    strcpy (buffy, szUserArguments);
        //    ClanData->rgMemberNames[cnum] = str_dup (buffy);
        //    send_to_char ("Clan member added!\n\r", chr);
        //    sprintf (buffy, "%s is now a member of the clan!", szUserArguments);
        //    clan_notify (buffy, ClanData->vnumClan);
        //    save_clans ();
        //    return;
        //  }
        //  return;
        //}

        //void do_cremove (CharacterData  chr, string szUserArguments)
        //{
        //  CLAN_DATA *ClanData;
        //  DEFINE_COMMAND ("cremove", do_cremove, POSITION_DEAD, 0, NORMAL, "Removes a member of the clan.  For the clan clanLeader only.")

        //    if (IS_MOB (chr))
        //    return;
        //  if (clan_number (chr) < 1)
        //    {
        //      send_to_char ("You are not a clan clanLeader!!\n\r", chr);
        //      return;
        //    }
        //  if (szUserArguments == "" || szUserArguments[0] == '\0')
        //    {
        //      send_to_char ("Syntax: CREMOVE <membername>\n\r", chr);
        //      return;
        //    }
        //  ClanData = get_clan_index (clan_number (chr));
        //  if (str_cmp (chr->pcdata->name, ClanData->clanLeader))
        //    {
        //      send_to_char ("Only the clan clanLeader may remove rgMemberNames.\n\r", chr);
        //      return;
        //    }
        //  {
        //    int i;
        //    bool foundy;
        //    foundy = FALSE;
        //    for (i = 0; i < 100; i++)
        //      {
        //   if (!str_cmp (ClanData->rgMemberNames[i], szUserArguments))
        //     {
        //       free_string (ClanData->rgMemberNames[i]);
        //       ClanData->rgMemberNames[i] = NULL;
        //       foundy = TRUE;
        //       break;
        //     }
        //      }
        //    if (foundy)
        //      send_to_char ("Clan member removed.\n\r", chr);
        //    else
        //      send_to_char ("Clan member not found.\n\r", chr);
        //    save_clans ();
        //    return;
        //  }
        //  return;
        //}

        //void do_clan_quit (CharacterData  chr, string szUserArguments)
        //{
        //  int k;
        //  CLAN_DATA *ClanData;
        //  DEFINE_COMMAND ("cquit", do_clan_quit, POSITION_DEAD, 0, NORMAL, "Allows you to leave your current clan.")

        //    k = clan_number (chr);
        //  if (k < 1)
        //    {
        //      send_to_char ("You must first be in a clan before you can leave the clan!\n\r", chr);
        //      return;
        //    }
        //  ClanData = get_clan_index (k);
        //  if (ClanData != NULL)
        //    {
        //      int i;
        //      bool foundy;
        //      char buffy[STD_LENGTH];
        //      foundy = FALSE;
        //      for (i = 0; i < 100; i++)
        //   {
        //     if (!str_cmp (ClanData->rgMemberNames[i], NAME (chr)))
        //       {
        //         free_string (ClanData->rgMemberNames[i]);
        //         ClanData->rgMemberNames[i] = NULL;
        //         foundy = TRUE;
        //         break;
        //       }
        //   }
        //      if (foundy)
        //   send_to_char ("You have left the clan.\n\r", chr);
        //      else
        //   send_to_char ("Clan member not found.\n\r", chr);
        //      sprintf (buffy, "%s has left the clan!!", NAME (chr));
        //      clan_notify (buffy, k);
        //      save_clans ();
        //      return;
        //    }
        //  return;
        //}

        //void clan_check_align (CharacterData  chr)
        //{
        //  int ii;
        //  int i;
        //  int ali;
        //  CLAN_DATA *ClanData;
        //  ii = clan_number (chr);
        //  if (ii < 1)
        //    return;
        //  ClanData = get_clan_index (ii);
        //  ali = ClanData->alignment;
        //  if (ali == 0 && !IS_NEUTRAL (chr))
        //    {
        //      send_to_char ("You are no longer a member of your clan because of your alignment change!\n\r", chr);
        //      for (i = 0; i < 100; i++)
        //   {
        //     if (!str_cmp (ClanData->rgMemberNames[i], RNAME (chr)))
        //       {
        //         free_string (ClanData->rgMemberNames[i]);
        //         ClanData->rgMemberNames[i] = NULL;
        //         break;
        //       }
        //   }
        //      if (!str_cmp (ClanData->clanLeader, RNAME (chr)))
        //   strcpy (ClanData->clanLeader, "Leaderless!");
        //      return;
        //    }
        //  if (ali == 1 && !IS_GOOD (chr))
        //    {
        //      send_to_char ("You are no longer a member of your clan because of your alignment change!\n\r", chr);
        //      for (i = 0; i < 100; i++)
        //   {
        //     if (!str_cmp (ClanData->rgMemberNames[i], RNAME (chr)))
        //       {
        //         free_string (ClanData->rgMemberNames[i]);
        //         ClanData->rgMemberNames[i] = NULL;
        //         break;
        //       }
        //   }
        //      if (!str_cmp (ClanData->clanLeader, RNAME (chr)))
        //   strcpy (ClanData->clanLeader, "Leaderless!");
        //      return;
        //    }
        //  if (ali == 3 && IS_EVIL (chr))
        //    {
        //      send_to_char ("You are no longer a member of your clan because of your alignment change!\n\r", chr);
        //      for (i = 0; i < 100; i++)
        //   {
        //     if (!str_cmp (ClanData->rgMemberNames[i], RNAME (chr)))
        //       {
        //         free_string (ClanData->rgMemberNames[i]);
        //         ClanData->rgMemberNames[i] = NULL;
        //         break;
        //       }
        //   }
        //      if (!str_cmp (ClanData->clanLeader, RNAME (chr)))
        //   strcpy (ClanData->clanLeader, "Leaderless!");
        //      return;
        //    }
        //  if (ali == 2 && !IS_EVIL (chr))
        //    {
        //      send_to_char ("You are no longer a member of your clan because of your alignment change!\n\r", chr);
        //      for (i = 0; i < 100; i++)
        //   {
        //     if (!str_cmp (ClanData->rgMemberNames[i], RNAME (chr)))
        //       {
        //         free_string (ClanData->rgMemberNames[i]);
        //         ClanData->rgMemberNames[i] = NULL;
        //         break;
        //       }
        //   }
        //      if (!str_cmp (ClanData->clanLeader, RNAME (chr)))
        //   strcpy (ClanData->clanLeader, "Leaderless!");
        //      return;
        //    }
        //  return;
        //}

        //int clan_number (CharacterData  chr)
        //{
        //  CLAN_DATA *clan;
        //  int j;
        //  if (IS_MOB (chr))
        //    return -1;
        //  for (j = 0; j < 20; j++)
        //    {
        //      for (clan = clan_index_hash[j]; clan != NULL; clan = clan->next)
        //   {
        //     int i;
        //     if (!str_cmp (RNAME (chr), clan->clanLeader))
        //       return clan->vnumClan;
        //     for (i = 0; i < 100; i++)
        //       {
        //         if (clan->rgMemberNames[i] != NULL && !str_cmp (RNAME (chr), clan->rgMemberNames[i]))
        //      {
        //        return clan->vnumClan;
        //      }
        //       }
        //   }
        //    }
        //  return -1;
        //}

        //int clan_number_2 (CharacterData  chr)
        //{
        //  CLAN_DATA *clan;
        //  if (IS_MOB (chr))
        //    return -1;
        //  for
        //    (clan = get_clan_index_2 (1); clan != NULL; clan = get_clan_index_2 (clan->vnumClan + 1) /*clan->next */ )
        //    {
        //      int i;
        //      if (!str_cmp (RNAME (chr), clan->clanLeader))
        //   return clan->vnumClan;
        //      for (i = 0; i < 100; i++)
        //   {
        //     if (clan->rgMemberNames[i] != NULL && !str_cmp (RNAME (chr), clan->rgMemberNames[i]))
        //       {
        //         return clan->vnumClan;
        //       }
        //   }
        //    }
        //  return -1;
        //}

        //bool scan_clan_2 (string arg)
        //{
        //  CLAN_DATA *clan;
        //  for
        //    (clan = get_clan_index_2 (1); clan != NULL; clan = get_clan_index_2 (clan->vnumClan + 1) /*clan->next */ )
        //    {
        //      int i;
        //      if (!str_cmp (arg, clan->clanLeader))
        //   return TRUE;
        //      for (i = 0; i < 100; i++)
        //   {
        //     if (clan->rgMemberNames[i] != NULL && !str_cmp (arg, clan->rgMemberNames[i]))
        //       {
        //         return TRUE;
        //       }
        //   }
        //    }
        //  return FALSE;
        //}

        //bool check_clan (CLAN_DATA * clan, string szUserArguments)
        //{
        //  int i;
        //  if (!str_cmp (szUserArguments, clan->clanLeader))
        //    return TRUE;
        //  for (i = 0; i < 100; i++)
        //    {
        //      if (clan->rgMemberNames[i] == NULL)
        //   continue;
        //      if (!str_cmp (clan->rgMemberNames[i], szUserArguments))
        //   return TRUE;
        //    }
        //  return FALSE;
        //}



        //bool scan_clan (string arg)
        //{
        //  CLAN_DATA *clan;
        //  for
        //    (clan = get_clan_index (1); clan != NULL; clan = get_clan_index (clan->vnumClan + 1) /*clan->next */ )
        //    {
        //      int i;
        //      if (!str_cmp (arg, clan->clanLeader))
        //   return TRUE;
        //      for (i = 0; i < 100; i++)
        //   {
        //     if (clan->rgMemberNames[i] != NULL && !str_cmp (arg, clan->rgMemberNames[i]))
        //       {
        //         return TRUE;
        //       }
        //   }
        //    }
        //  return FALSE;
        //}

        //int clan_free (CLAN_DATA * clan)
        //{
        //  int i;
        //  for (i = 0; i < 100; i++)
        //    {
        //      if (clan->rgMemberNames[i] == NULL)
        //   return i;
        //    }
        //  return -1;
        //}

        //void do_clan (CharacterData  chr, string szUserArguments)	/*CLANS by Owen Emlen */
        //{
        //  int ii;
        //  char buf[450];
        //  CLAN_DATA *t;
        //  DEFINE_COMMAND ("clan", do_clan, POSITION_DEAD, 0, NORMAL, "Shows 'clan list' or clan info on your current clan.")

        //    if (!str_cmp (szUserArguments, "list"))
        //    {
        //      int i;
        //      for (i = 0; i < 20; i++)
        //   {
        //     for (t = clan_index_hash[i]; t != NULL; t = t->next)
        //       {
        //         sprintf (buf, "%d) %s\n\r", t->vnumClan, t->name);
        //         send_to_char (buf, chr);
        //       }
        //   }

        //      return;
        //    }
        //  ii = clan_number (chr);
        //  if (ii < 1)
        //    {
        //      send_to_char ("You aren't in a clan!\n\r", chr);
        //      return;
        //    }
        //  sprintf (buf, "%d", ii);
        //  do_cindex (chr, buf);
        //  return;
        //}

        //void do_clan_2 (CharacterData  chr, string szUserArguments)	/*CLANS by Owen Emlen */
        //{
        //  int ii;
        //  char buf[450];
        //  CLAN_DATA *t;
        //  DEFINE_COMMAND ("sect", do_clan_2, POSITION_DEAD, 0, NORMAL, "Shows 'sect list' or clan info on your current clan.")
        //    if (!str_cmp (szUserArguments, "list"))
        //    {
        //      int i;
        //      for (i = 0; i < 20; i++)
        //   {
        //     for (t = clan_index_hash_2[i]; t != NULL; t = t->next)
        //       {
        //         sprintf (buf, "%d) %s\n\r", t->vnumClan, t->name);
        //         send_to_char (buf, chr);
        //       }
        //   }

        //      return;
        //    }
        //  ii = clan_number_2 (chr);
        //  if (ii < 1)
        //    {
        //      send_to_char ("You aren't in a secondary clan!\n\r", chr);
        //      return;
        //    }
        //  sprintf (buf, "%d", ii);
        //  do_cindex_2 (chr, buf);
        //  return;
        //}



        //bool 
        //not_is_same_align (CharacterData  chr, CharacterData  victim)
        //{
        //  return
        //    (IS_PLAYER (chr) && !IS_MOB (victim) && LEVEL (chr) < 101 && LEVEL (victim) < 101 &&
        //     ((IS_SET (victim->pcdata->raceflag, RC_EVILRACE) && !IS_SET (chr->pcdata->raceflag, RC_EVILRACE)) ||
        //      (!IS_SET (victim->pcdata->raceflag, RC_EVILRACE) && IS_SET (chr->pcdata->raceflag, RC_EVILRACE))
        //     ));
        //}


    }
}
